<?php  if (!defined('BASEPATH')) exit('No direct script access allowed');

class CI_Countries_entity{
	var $current_dbprefix = "";
	var $CI;
	var $id = 0;
	var $country_code ="";
	var $country_name = '';
	 
	function __construct() {
		$this->CI= & get_instance();
		$this->current_dbprefix = $this->CI->db->dbprefix;
		$this->CI->db->set_dbprefix('default_');
	}
	function __destruct() {
		$this->CI->db->set_dbprefix($this->current_dbprefix);
	}
	function init($cmd, $input)
	{
		$this->CI->db->set_dbprefix('default_');
		
		if($cmd == 'id')
		{
			$result = $this->CI->db->where('id',$input)->get(TBL_COUNTRY)->result();
		}
		else if($cmd == 'code')
		{
			$result = $this->CI->db->where('country_code',$input)->get(TBL_COUNTRY)->result();
		}else
		{
			return false;
		}
		if( !empty($result) )
		{
			$this->id = $result[0]->id;
			$this->country_code = $result[0]->country_code;
			$this->country_name = $result[0]->country_name;
			return $this;
		}
		return false;
	}
	
	function getId(){return $this->id;}
	function getCountryCode(){return $this->country_code;}
	function getCountryName(){return $this->country_name;}	
	
	function getBornCountryData($id){
		$this->CI->db->set_dbprefix('default_');
		$rs = $this->CI->db->where('id',$id)->get('default_escort_born_countries')->result();
		return $rs[0];
	}
	
	//end class
}	